package LC;

import java.util.Stack;

/**
 * @ClassName MinStack
 * @Description: TODO
 * @Author hl
 * @Date 2020/6/7
 * @Version V1.0
 **/
public class MinStack {
    Stack<Integer> stack=new Stack<>();
    Stack<Integer> minStack=new Stack<>();

    public void push(int node) {
        stack.push(node);
        if(minStack.isEmpty()){
           minStack.push(node);
        }else {
            if(minStack.peek()>node){
                minStack.push(node);
            }else{
                minStack.push(minStack.peek());
            }
        }
    }

    public void pop() {
        stack.pop();
        minStack.pop();
    }

    public int top() {
        return stack.peek();

    }

    public int min() {
    return minStack.peek();
    }
}
